import axios from "axios";
import Cookie from "js-cookie";

const instance = axios.create({
    baseURL: "http://120.24.64.5:8088/mall-admin",
    timeout: 10000
})

// 拦截求
instance.interceptors.request.use(config => {
    let token = Cookie.get("token");
    if (token) {
        config.headers = config.headers || {}
        config.headers.Authorization = token
    }
    return config;
}, error => {
    return Promise.reject(error);
})

// 拦截求
instance.interceptors.response.use(resp => {
    return resp.data;
}, error => {
    return Promise.reject(error);
})

export default instance;
